//
//  showInfoBusesController.m
//  ElektroM
//
//  Created by Michael on 19.10.09.
//  Copyright 2009 Artgruppe inc. All rights reserved.
//

#import "showInfoBusesController.h"


@implementation showInfoBusesController
@synthesize strInfo, strTime;
@synthesize table;
@synthesize strTitle;

/*
- (id)initWithStyle:(UITableViewStyle)style {
    // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
    if (self = [super initWithStyle:style]) {
    }
    return self;
}
*/

/*
- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
	[self.navigationItem setTitle:strTitle];
	[table reloadData];
}

/*
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}
*/
/*
- (void)viewWillDisappear:(BOOL)animated {
	[super viewWillDisappear:animated];
}
*/

- (void)viewDidDisappear:(BOOL)animated {
	[super viewDidDisappear:animated];
	[table reloadData];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	self.table=nil;
	self.strInfo=nil;
	self.strTitle=nil;
	self.strTime=nil;
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{	
	switch (indexPath.row) {
		case 0:
			return 38.0;
			
			break;
		case 1:
			return 50.0;			
			break;
		case 2:
			return 38.0;
			
			break;
		case 3:
			return [strInfo length]/1.8;
			
			break;
		default:
			break;
	}
	return (!_bOneUsed) ? 50.0:[strInfo length]/1.8 /*350*/;
	return ([indexPath row] == 0) ? 50.0:[strInfo length]/1.8 /*350*/;
}



#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}


// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
	UITableViewCell *cell = nil;
	
	static NSString *kSourceCellID = @"SourceCellID";
	cell = [self.tableView dequeueReusableCellWithIdentifier:kSourceCellID];
	if (cell == nil)
	{
		cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kSourceCellID] autorelease];
		cell.selectionStyle = UITableViewCellSelectionStyleNone;
		
		cell.textLabel.opaque = NO;
		cell.textLabel.textAlignment = UITextAlignmentLeft;
		cell.textLabel.textColor = [UIColor blackColor];
		cell.textLabel.numberOfLines = 1;
		//cell.textLabel.highlightedTextColor = [UIColor blueColor];
		cell.textLabel.font = [UIFont systemFontOfSize:14];		
	}
	if ([indexPath row] == 0)
	{
		cell.textLabel.numberOfLines=1;
		cell.textLabel.textColor = [UIColor blackColor];
		cell.textLabel.textAlignment = UITextAlignmentRight;
		cell.textLabel.textColor = [UIColor blueColor];
		cell.textLabel.font = [UIFont systemFontOfSize:18];	
		
		cell.textLabel.text = NSLocalizedString(@"Time", @"");
		
	}
	else if ([indexPath row] == 1 /*&& !_bOneUsed*/)
	{	
		cell.textLabel.numberOfLines=1;
		cell.textLabel.text = strTime;		
	}
	else if([indexPath row] == 2)
		
	{
		cell.textLabel.numberOfLines=1;
		cell.textLabel.textColor = [UIColor blackColor];
		cell.textLabel.textAlignment = UITextAlignmentRight;
		cell.textLabel.textColor = [UIColor blueColor];
		cell.textLabel.font = [UIFont systemFontOfSize:18];	
		
		cell.textLabel.text = NSLocalizedString(@"Path", @"");
	}
	else if([indexPath row]==3 /*&& _bOneUsed*/)
	{				
		cell.textLabel.numberOfLines = [strInfo length]/20;
		cell.textLabel.text = strInfo;			
	}
	//_bOneUsed=!_bOneUsed;
	return cell;
}
/*
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
	if(section==0)
		return NSLocalizedString(@"Time", @"");
	else
		return NSLocalizedString(@"Path", @"");
}
 */ 
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
	// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
	// [self.navigationController pushViewController:anotherViewController];
	// [anotherViewController release];
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/


/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/


/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/
/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/


- (void)dealloc {
	self.table=nil;
	self.strInfo=nil;
	self.strTitle=nil;
	self.strTime=nil;
    [super dealloc];
}


@end

